package com.pengheng.bean;

import lombok.Data;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.FieldStrategy;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;

import java.util.List;

@Data
@IndexName
public class Document {
    /**
     * 该类型为未设置主键类型,由es自动生成
     * NONE
     * 全局唯一ID (UUID)
     * UUID
     * 用户自定义,由用户传入
     * CUSTOMIZE
     */
    @IndexId(type = IdType.CUSTOMIZE)
    private String id;
    /**
     * 文档标题
     */
    @HighLight(preTag = "<font color = 'red'>", postTag = "</font>")
    private String title;

    /**
     * 岁数
     */
    private Integer age;

    /**
     * 类型
     */
    private Integer type;

    /**
     * **尺寸
     */
    private Integer size;


    /**
     * 地图数据
     */
    @IndexField(fieldType = FieldType.GEO_POINT)
    private String location;

    /**
     * 图形(例如圆心,矩形)
     */
    @IndexField(fieldType = FieldType.GEO_SHAPE)
    private String geoLocation;

    /**
     * 创建时间
     */
    @IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private String gmtCreate;

    /**
     * 嵌套用户
     */
    @IndexField(fieldType = FieldType.NESTED, nestedClass = User.class)
    private List<User> users;

    /**
     * 文档内容
     */
    // 场景二:更新时,此字段非空字符串才会被更新
    @IndexField(strategy = FieldStrategy.NOT_EMPTY)
    private String content;
}
